<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>排序算法大观</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        .complexity-badge {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            color: white;
            padding: 0.25rem 0.75rem;
            border-radius: 9999px;
            font-size: 0.875rem;
            font-weight: 500;
        }
        .algorithm-card {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.3);
        }
        .drop-cap {
            float: left;
            font-size: 4rem;
            line-height: 1;
            font-weight: 700;
            margin-right: 0.5rem;
            color: #667eea;
            font-family: 'Noto Serif SC', serif;
        }
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
        .section-divider {
            height: 2px;
            background: linear-gradient(to right, transparent, #e0e0e0, transparent);
            margin: 3rem 0;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-6">
        <div class="max-w-6xl mx-auto text-center">
            <h1 class="text-5xl md:text-7xl font-bold mb-6 tracking-tight">
                <i class="fas fa-sort-amount-up mr-4"></i>排序算法大观
            </h1>
            <p class="text-xl md:text-2xl font-light max-w-3xl mx-auto leading-relaxed">
                探索计算机科学中最基础却又最精妙的算法世界，从简单到复杂，从低效到高效，每一种算法都有其独特的魅力与适用场景
            </p>
        </div>
    </section>

    <!-- Introduction -->
    <section class="py-16 px-6">
        <div class="max-w-4xl mx-auto">
            <div class="bg-white rounded-2xl shadow-xl p-8 md:p-12">
                <p class="text-lg leading-relaxed text-gray-700">
                    <span class="drop-cap">排</span>序是计算机科学中一个基本而重要的操作。常见的排序算法有很多，每种算法都有其适用的场景和优缺点。让我们一起深入探索这些算法的奥秘，理解它们的工作原理、性能特征以及最佳应用场景。
                </p>
            </div>
        </div>
    </section>

    <!-- Visualization Section -->
    <section class="py-12 px-6">
        <div class="max-w-6xl mx-auto">
            <h2 class="text-3xl font-bold text-center mb-8 text-gray-800">算法复杂度对比图</h2>
            <div class="bg-white rounded-2xl shadow-xl p-8">
                <div class="mermaid">
                    graph TD
                        A[排序算法] --> B[O(n²) 算法]
                        A --> C[O(n log n) 算法]
                        A --> D[O(n) 算法]
                        
                        B --> E[冒泡排序]
                        B --> F[选择排序]
                        B --> G[插入排序]
                        
                        C --> H[归并排序]
                        C --> I[快速排序]
                        C --> J[堆排序]
                        
                        D --> K[计数排序]
                        D --> L[桶排序]
                        D --> M[基数排序]
                        
                        style A fill:#667eea,stroke:#fff,stroke-width:2px,color:#fff
                        style B fill:#f093fb,stroke:#fff,stroke-width:2px,color:#fff
                        style C fill:#4facfe,stroke:#fff,stroke-width:2px,color:#fff
                        style D fill:#43e97b,stroke:#fff,stroke-width:2px,color:#fff
                </div>
            </div>
        </div>
    </section>

    <div class="section-divider"></div>

    <!-- Algorithms Grid -->
    <section class="py-16 px-6">
        <div class="max-w-7xl mx-auto">
            <h2 class="text-4xl font-bold text-center mb-12 text-gray-800">
                <i class="fas fa-layer-group mr-3"></i>十大经典排序算法
            </h2>
            
            <div class="grid grid-cols-1 md:grid-cols-2 gap-8">
                <!-- 冒泡排序 -->
                <div class="algorithm-card rounded-2xl p-8 card-hover">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 bg-gradient-to-br from-purple-500 to-pink-500 rounded-full flex items-center justify-center text-white font-bold text-xl mr-4">1</div>
                        <h3 class="text-2xl font-bold text-gray-800">冒泡排序</h3>
                        <span class="ml-auto complexity-badge">O(n²)</span>
                    </div>
                    <p class="text-gray-600 mb-4">通过重复地比较相邻的元素并交换它们，如果它们的顺序错误。这种过程会在每次遍历时把最大（或最小）的元素"冒泡"到数组的末尾。</p>
                    <div class="space-y-2 text-sm">
                        <div class="flex items-center">
                            <i class="fas fa-clock text-blue-500 mr-2"></i>
                            <span class="text-gray-700">时间复杂度：O(n²)</span>
                        </div>
                        <div class="flex items-center">
                            <i class="fas fa-memory text-green-500 mr-2"></i>
                            <span class="text-gray-700">空间复杂度：O(1)</span>
                        </div>
                        <div class="flex items-center">
                            <i class="fas fa-check-circle text-green-500 mr-2"></i>
                            <span class="text-gray-700">简单易懂，适用于少量数据</span>
                        </div>
                        <div class="flex items-center">
                            <i class="fas fa-times-circle text-red-500 mr-2"></i>
                            <span class="text-gray-700">效率低，适合小规模数据排序</span>
                        </div>
                    </div>
                </div>

                <!-- 选择排序 -->
                <div class="algorithm-card rounded-2xl p-8 card-hover">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 bg-gradient-to-br from-blue-500 to-cyan-500 rounded-full flex items-center justify-center text-white font-bold text-xl mr-4">2</div>
                        <h3 class="text-2xl font-bold text-gray-800">选择排序</h3>
                        <span class="ml-auto complexity-badge">O(n²)</span>
                    </div>
                    <p class="text-gray-600 mb-4">每次从未排序部分中选择最小（或最大）的元素，将其放到已排序部分的末尾。</p>
                    <div class="space-y-2 text-sm">
                        <div class="flex items-center">
                            <i class="fas fa-clock text-blue-500 mr-2"></i>
                            <span class="text-gray-700">时间复杂度：O(n²)</span>
                        </div>
                        <div class="flex items-center">
                            <i class="fas fa-memory text-green-500 mr-2"></i>
                            <span class="text-gray-700">空间复杂度：O(1)</span>
                        </div>
                        <div class="flex items-center">
                            <i class="fas fa-check-circle text-green-500 mr-2"></i>
                            <span class="text-gray-700">简单，内存使用少</span>
                        </div>
                        <div class="flex items-center">
                            <i class="fas fa-times-circle text-red-500 mr-2"></i>
                            <span class="text-gray-700">性能差，不适合大型数据集</span>
                        </div>
                    </div>
                </div>

                <!-- 插入排序 -->
                <div class="algorithm-card rounded-2xl p-8 card-hover">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 bg-gradient-to-br from-green-500 to-teal-500 rounded-full flex items-center justify-center text-white font-bold text-xl mr-4">3</div>
                        <h3 class="text-2xl font-bold text-gray-800">插入排序</h3>
                        <span class="ml-auto complexity-badge">O(n²)</span>
                    </div>
                    <p class="text-gray-600 mb-4">将未排序部分的元素逐个插入到已排序部分的合适位置。通常在部分已排序的数组上效率较高。</p>
                    <div class="space-y-2 text-sm">
                        <div class="flex items-center">
                            <i class="fas fa-clock text-blue-500 mr-2"></i>
                            <span class="text-gray-700">时间复杂度：O(n²)（最坏），O(n)（最好）</span>
                        </div>
                        <div class="flex items-center">
                            <i class="fas fa-memory text-green-500 mr-2"></i>
                            <span class="text-gray-700">空间复杂度：O(1)</span>
                        </div>
                        <div class="flex items-center">
                            <i class="fas fa-check-circle text-green-500 mr-2"></i>
                            <span class="text-gray-700">简单，适用于小规模或几乎已排序的数据</span>
                        </div>
                        <div class="flex items-center">
                            <i class="fas fa-times-circle text-red-500 mr-2"></i>
                            <span class="text-gray-700">在大数据集上效率低</span>
                        </div>
                    </div>
                </div>

                <!-- 归并排序 -->
                <div class="algorithm-card rounded-2xl p-8 card-hover">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 bg-gradient-to-br from-yellow-500 to-orange-500 rounded-full flex items-center justify-center text-white font-bold text-xl mr-4">4</div>
                        <h3 class="text-2xl font-bold text-gray-800">归并排序</h3>
                        <span class="ml-auto complexity-badge" style="background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);">O(n log n)</span>
                    </div>
                    <p class="text-gray-600 mb-4">将数组分割成两个子数组，分别对这两个子数组进行排序，然后合并这两个已排序的子数组。</p>
                    <div class="space-y-2 text-sm">
                        <div class="flex items-center">
                            <i class="fas fa-clock text-blue-500 mr-2"></i>
                            <span class="text-gray-700">时间复杂度：O(n log n)</span>
                        </div>
                        <div class="flex items-center">
                            <i class="fas fa-memory text-orange-500 mr-2"></i>
                            <span class="text-gray-700">空间复杂度：O(n)</span>
                        </div>
                        <div class="flex items-center">
                            <i class="fas fa-check-circle text-green-500 mr-2"></i>
                            <span class="text-gray-700">稳定排序，时间复杂度为O(n log n)</span>
                        </div>
                        <div class="flex items-center">
                            <i class="fas fa-times-circle text-red-500 mr-2"></i>
                            <span class="text-gray-700">需要额外的内存空间</span>
                        </div>
                    </div>
                </div>

                <!-- 快速排序 -->
                <div class="algorithm-card rounded-2xl p-8 card-hover">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 bg-gradient-to-br from-red-500 to-pink-500 rounded-full flex items-center justify-center text-white font-bold text-xl mr-4">5</div>
                        <h3 class="text-2xl font-bold text-gray-800">快速排